package com.android.phoenix.bluetooth;

import com.android.phoenix.R;



import com.android.phoenix.activity.SportActivity;

import android.app.Activity;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class BluConnectFinishActivity extends Activity {
	private ImageView title_Imgbtn_left_up;
	private TextView title_txt_center;
	private TextView txt_blutooth_connected_device;
	private Button btn_blu_disconnect;
	private BluetoothDevice device;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.acti_blutooth_connect_finish);
		// 初始化一些控件
		initView();
		// 初始化titleBar
		initTitleBar();		
	}
	/**
	 * 
	 * @Title: initTitleBar
	 * @Description: TODO(设置统一的titleBar)
	 * @author: wWX230766
	 * @date: 2015-1-6 下午10:00:48
	 */
	private void initTitleBar() {
		title_Imgbtn_left_up = (ImageView) this
				.findViewById(R.id.title_Imgbtn_left_up);
		title_txt_center = (TextView) this.findViewById(R.id.title_txt_center);
		title_txt_center.setText(R.string.label_blutooth_connect);
		title_Imgbtn_left_up.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent it = new Intent();
				it.setClass(BluConnectFinishActivity.this, SportActivity.class);
				startActivity(it);
				finish();
			}
		});
	}
	private void initView()
	{
		device = getIntent().getExtras().getParcelable("Device");
		txt_blutooth_connected_device = (TextView)findViewById(R.id.txt_blutooth_connected_device);
		txt_blutooth_connected_device.setText(device.getName());
		btn_blu_disconnect = (Button)findViewById(R.id.btn_blu_disconnect);
		btn_blu_disconnect.setOnClickListener(new OnClickListener() {			
			@Override
			public void onClick(View view) {
				// TODO Auto-generated method stub
				Intent it = new Intent(BluConnectFinishActivity.this,BluetoothService.class);	
				stopService(it);
				it.setClass(BluConnectFinishActivity.this, SportActivity.class);
				startActivity(it);
				finish();
			}
		});
	}
	
}
